package cn.awenhui;

import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;
import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;


import java.io.*;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) throws IOException {
        // 设置输入输出文件路径
        String inputFilePath = "D:\\demo\\openoffice\\赛领公寓后端项目交接文档.docx";
        String outputFilePath = "D:\\demo\\openoffice\\赛领公寓后端项目交接文档.pdf";

        // 创建输入输出文件对象
        File inputFile = new File(inputFilePath);
        File outputFile = new File(outputFilePath);
        FileInputStream fis = new FileInputStream(inputFile);
        FileOutputStream fos = new FileOutputStream(outputFile);
        XWPFDocument document = new XWPFDocument(fis);
        PdfOptions options = PdfOptions.create();


        PdfConverter.getInstance().convert(document, fos, options);
        fis.close();
        fos.close();
    }
}